<%@page import="dao.BookDao"%>
<%@page import="entity.Book"%>
<%@page import="entity.Address"%>
<%@page import="dao.AddressDao"%>
<%@page import="entity.OrderInfo"%>
<%@page import="entity.OrderForm"%>
<%@page import="dao.OrderDao"%>
<%@page import="java.util.List"%>
<%@page import="entity.Member"%>
<%@page import="dao.MemberDao"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page errorPage="error.jsp" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" charset="utf-8" />
        <style>
            p{
                font-size: 15px;
            }
        </style>
    </head>
    <body>
        <div class="container">
                <h1 class="text-primary text-center">用户信息</h1>
                <div style="position:absolute;right:200px;top:10px">
                        <h3><a href="Admin.jsp" class="btn btn-sm btn-warning text-center">返回管理界面</a></h3>
                </div>
                <br>
                <%
                    int userId=Integer.parseInt(request.getParameter("userid"));
                    Member member=new MemberDao().getMemberById(userId);
                %>
                <p>姓名：<%=member.getName()%></p>
                <p>性别：<%=member.getGender()%></p>
                <p>手机号：<%=member.getPhone()%></p>
                <p>邮箱：<%=member.getEmail()%></p>
                <p>职业：<%=member.getProfession()%></p>
                <p>感兴趣书籍：<%=member.getLiketype()%></p>

                <h3 class="text-success text-center">订单列表</h3>
                <table class="table table-condensed table-striped" style="width: 900px">
                            <tr>
                                <th>订单号</th><th>订单时间</th><th>地址</th><th>收件人</th>
                                <th>书名</th><th>件数</th><th></th>
                            </tr>
                            <%
                                    List<OrderForm> orderformList=new OrderDao().getAllOrderForm(userId);
                                    for(int i=orderformList.size()-1;i>=0;i--){
                                        List<OrderInfo> orderinfoList=new OrderDao().getOrderInfo(orderformList.get(i).getId());
                                        Address address=new AddressDao().getAddressById(orderformList.get(i).getAddressId());
                            %>
                                <tr>
                                    <td><%=orderformList.get(i).getId()%></td><td><%=orderformList.get(i).getOrderDate()%></td>
                                    <td><%=address.getAddress()%></td><td><%=address.getAddressee()%></td>
                                    <td><ul>
                                <%
                                        for(int j=0;j<orderinfoList.size();j++){
                                            Book book=new BookDao().getBookById(orderinfoList.get(j).getBookId());                                   
                                %>
                                                    <li><%=book.getBookName()%></li>                            
                                <%
                                        }
                                %>
                                        </ul></td>
                                        <td><ul>
                                 <%
                                                for(int j=0;j<orderinfoList.size();j++){
                                                        Book book=new BookDao().getBookById(orderinfoList.get(j).getBookId());
                                 %>
                                            <li><%=orderinfoList.get(j).getCount()%></li>
                                 <%
                                        }
                                 %>
                                        </ul></td><td><a href="OrderDetail.jsp?orderid=<%=orderformList.get(i).getId()%>&userid=<%=userId%>">查看详情</a></td>
                                  <%
                                         }
                                   %>
                        </table>
        </div>
    </body>
</html>
